USE [NANS21V]
GO

/****** オブジェクト:  StoredProcedure [dbo].[Rekidai_All]    スクリプト日付: 05/11/2018 17:30:46 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Rekidai_All]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Rekidai_All]
GO

CREATE PROCEDURE [dbo].[Rekidai_All]
    @TAIKAINO int
AS
SELECT 
    R.KYOGINO,
    R.SABUNO,
    C.COMMENTNO, 
    C.PRINTNO, 
    C.COMMENTRYAKU, 
    R.REKIDAINO, 
    R.KIROKU, 
    R.SENSYUMEI, 
    R.HIDUKE, 
    R.SOKUTEI, 
    C.COMMENTMEI 
FROM 
    TBL_REKIDAI AS R, 
    TBL_COMMENT AS C 
WHERE 
    R.TAIKAINO = @TAIKAINO 
    AND R.COMMENTNO = C.COMMENTNO
ORDER BY R.KYOGINO, R.SABUNO, C.PRINTNO